package com.ruoyi.web.controller.test7;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.test7.domain.RequestStatus;
import com.ruoyi.test7.service.IRequestStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * statusController
 * 
 * @author 22082109czy
 * @date 2025-07-13
 */
@RestController
@RequestMapping("/status/status")
public class RequestStatusController extends BaseController
{
    @Autowired
    private IRequestStatusService requestStatusService;

    /**
     * 查询status列表
     */
    @PreAuthorize("@ss.hasPermi('status:status:list')")
    @GetMapping("/list")
    public TableDataInfo list(RequestStatus requestStatus)
    {
        startPage(); // 启动分页
        List<RequestStatus> list = requestStatusService.selectRequestStatusList(requestStatus);
        return getDataTable(list); // 使用父类BaseController提供的getDataTable方法
    }

    /**
     * 导出status列表
     */
    @PreAuthorize("@ss.hasPermi('status:status:export')")
    @Log(title = "status", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RequestStatus requestStatus)
    {
        List<RequestStatus> list = requestStatusService.selectRequestStatusList(requestStatus);
        ExcelUtil<RequestStatus> util = new ExcelUtil<RequestStatus>(RequestStatus.class);
        util.exportExcel(response, list, "status数据");
    }

    /**
     * 获取status详细信息
     */
    @PreAuthorize("@ss.hasPermi('status:status:query')")
    @GetMapping(value = "/{statusId}")
    public AjaxResult getInfo(@PathVariable("statusId") Long statusId)
    {
        return success(requestStatusService.selectRequestStatusByStatusId(statusId));
    }

    /**
     * 新增status
     */
    @PreAuthorize("@ss.hasPermi('status:status:add')")
    @Log(title = "status", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RequestStatus requestStatus)
    {
        return toAjax(requestStatusService.insertRequestStatus(requestStatus));
    }

    /**
     * 修改status
     */
    @PreAuthorize("@ss.hasPermi('status:status:edit')")
    @Log(title = "status", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RequestStatus requestStatus)
    {
        return toAjax(requestStatusService.updateRequestStatus(requestStatus));
    }

    /**
     * 删除status
     */
    @PreAuthorize("@ss.hasPermi('status:status:remove')")
    @Log(title = "status", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statusIds}")
    public AjaxResult remove(@PathVariable Long[] statusIds)
    {
        return toAjax(requestStatusService.deleteRequestStatusByStatusIds(statusIds));
    }
}
